package org.bsc.mgwt.client.widget;

import org.bsc.mgwt.client.MobileResourceAware;
import org.bsc.mgwt.client.res.ProgressPanelCss;

import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasHTML;
import com.googlecode.mgwt.ui.client.widget.LayoutPanel;
import com.googlecode.mgwt.ui.client.widget.ProgressIndicator;

/**
 * 
 * @author bsorrentino
 *
 */
public class HeaderProgressIndicator extends LayoutPanel implements MobileResourceAware, HasHTML {

	protected final HTML title = new HTML("");
	protected ProgressIndicator indicator = new ProgressIndicator();
	
	public HeaderProgressIndicator() {		
		this( mobileBundleIPhone.progressPanel() );		
	}

	public HeaderProgressIndicator( ProgressPanelCss css ) {
		css.ensureInjected();
		
		super.addStyleName(css.panel());
		super.setHorizontal(true);

		indicator.addStyleName(css.spinner());

		add( indicator );
		
		title.addStyleName(css.message());
		
		add( title );
		
		stop();
		
		
	}

	@Override
	public String getHTML() {
		return title.getHTML();
	}

	@Override
	public void setHTML(String html) {
		title.setHTML(html);
	}

	@Override
	public String getText() {
		return title.getText();
	}

	@Override
	public void setText(String text) {
		title.setText(text);
	}
	
	public void start() {
		indicator.setVisible( true );
	}
	
	public void stop() {
		indicator.setVisible( false );		
	}
}